package com.mediacloud.app.newsmodule.activity.military_encyclopedia

import android.text.Html
import android.util.TypedValue
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.mediacloud.app.newsmodule.R

class MilitaryEncyclopediaEntryRefAdapter : BaseQuickAdapter<EntryRefList,BaseViewHolder>(R.layout.item_bk_entry_ref) {
    var zoom: Int = 0

    override fun convert(helper: BaseViewHolder, item:EntryRefList) {
        val tvSerial = helper.getView<TextView>(R.id.tvSerial)
        val tvContent = helper.getView<TextView>(R.id.tvContent)
        tvSerial.text = "[${item.refId}]"
        val text222 = "${item.articleTitle}·  ${item.websiteName}·  ${item.publishDate}"
        tvContent.text = Html.fromHtml(
            "<font color=\"#222222\">$text222 </font>"+"<font color=\"#999999\"> (引用日期${item.refDate})</font>"
        )
        if (zoom != 0){
            val textSize: Float = tvSerial.context.resources.getDimension(R.dimen.sp_17) * (zoom / 100f)
            tvSerial.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
            tvContent.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
        }
    }
    fun resizeText(zoom: Int){
        this.zoom = zoom
        notifyDataSetChanged()
    }

}